﻿using SqlSugar;
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using GKQC.DbHelper.ViewModels;

namespace GKQC.DbHelper.DbModels
{
	//研发检测单单次测试资料
	[SugarTable("t_rnd_dtl")]
	public class RndDtlModel
	{

		public RndDtlModel()
		{
			this.TestDate = DateTime.Now;
			this.CreateDate = DateTime.Now;
			this.IsModified = true;
			if(this.ElectricViewModels == null)
				this.ElectricViewModels = new List<ElectricViewModel>();
			if(this.SizeViewModels == null )
				this.SizeViewModels = new List<SizeViewModel>();
			if(this.Datas == null)
				this.Datas = new List<RndDataModel>();
			this.Remark = string.Empty;
		}

		public RndDtlModel(int electricQty, int sizeQty, int sNo, long headId) : this()
		{
			this.Datas = new List<RndDataModel>();
			this.ElectricViewModels = new List<ElectricViewModel>();
			this.SizeViewModels = new List<SizeViewModel>();
			this.SNo = sNo;
			this.HeadId = headId;
			GenerateList(electricQty, sizeQty, sNo);
		}

		public void GenerateList(int electricQty, int sizeQty, int sNo)
		{
			ViewModelTrans<RndDataModel>.GenerateTestList(electricQty, sizeQty, sNo, ElectricViewModels, SizeViewModels);
			this.IsModified = IsModified;
		}

		/// <summary>
		/// 流水号
		/// </summary>	
		[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
		public long Id { get; set; }
		/// <summary>
		/// 单头Id
		/// </summary>		
		public long HeadId { get; set; }
		/// <summary>
		/// 测试次数
		/// </summary>		
		public int SNo { get; set; }
		/// <summary>
		/// 检测日期
		/// </summary>		
		public DateTime TestDate { get; set; }
		/// <summary>
		/// 建立日期
		/// </summary>		
		public DateTime CreateDate { get; set; }
		/// <summary>
		/// 检验人员
		/// </summary>		
		public string CreateUser { get; set; }
		/// <summary>
		/// 试验条件
		/// </summary>		
		public string Condiction { get; set; }
		/// <summary>
		/// Z值频率
		/// </summary>		
		public string ZFreq { get; set; }
		/// <summary>
		/// Z值频率2
		/// </summary>		
		public string ZFreq2 { get; set; }
		/// <summary>
		/// 更新日期
		/// </summary>		
		public DateTime? ModiDate { get; set; }
		/// <summary>
		/// 修改人
		/// </summary>		
		public string ModiUser { get; set; }

		public string Remark { get; set; }

		[SugarColumn(IsIgnore = true)]
		public List<RndDataModel> Datas { get; set; }

		[SugarColumn(IsIgnore = true)]
		public List<ElectricViewModel> ElectricViewModels { get; set; }
		[SugarColumn(IsIgnore = true)]
		public List<SizeViewModel> SizeViewModels { get; set; }

		[SugarColumn(IsIgnore = true)]
		public bool IsModified { get; set; }
	}
}

